﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows;

namespace WPF_Preview.PreviewClass
{
    public class ExcelFileLoader
    {
        private string folderPath;
        public ExcelFileLoader(string folderPath)
        {
            this.folderPath = folderPath;
        }
        public void LoadExcelFilesToComboBox(ComboBox comboBox)
        {
            if (Directory.Exists(folderPath))
            {
                var files = Directory.GetFiles(folderPath, "*.xlsx");
                foreach (var file in files)
                {
                    comboBox.Items.Add(Path.GetFileName(file));
                }
            }
            else
            {
                MessageBox.Show("指定的Excel文件夹不存在：" + folderPath);
            }
        }
    }
}
